package com.yanfan.ccapi.controller;

import com.yanfan.ccapi.service.ICcapiActionMappingService;
import com.yanfan.ccapicode.dao.entity.ActionMappingDO;
import com.yanfan.common.annotation.Log;
import com.yanfan.common.core.controller.BaseController;
import com.yanfan.common.core.domain.AjaxResult;
import com.yanfan.common.core.page.TableDataInfo;
import com.yanfan.common.enums.BusinessType;
import com.yanfan.common.utils.poi.ExcelUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 操作技能映射Controller
 *
 * @author kerwincui
 * @date 2025-06-29
 */
@RestController
@RequestMapping("/ccapi/actionMapping")
@Api(tags = "操作技能映射")
public class CcapiActionMappingController extends BaseController {
    @Autowired
    private ICcapiActionMappingService ccapiActionMappingService;

    /**
     * 查询操作技能映射列表
     */
//@PreAuthorize("@ss.hasPermi('ccapi:actionMapping:list')")
    @GetMapping("/list")
    @ApiOperation("查询操作技能映射列表")
    public TableDataInfo list(ActionMappingDO ccapiActionMapping) {
        startPage();
        List<ActionMappingDO> list = ccapiActionMappingService.selectActionMappingList(ccapiActionMapping);
        return getDataTable(list);
    }

    /**
     * 导出操作技能映射列表
     */
    @ApiOperation("导出操作技能映射列表")
    //@PreAuthorize("@ss.hasPermi('ccapi:actionMapping:export')")
    @Log(title = "操作技能映射", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ActionMappingDO ccapiActionMapping) {
        List<ActionMappingDO> list = ccapiActionMappingService.selectActionMappingList(ccapiActionMapping);
        ExcelUtil<ActionMappingDO> util = new ExcelUtil<>(ActionMappingDO.class);
        util.exportExcel(response, list, "操作技能映射数据");
    }

    /**
     * 获取操作技能映射详细信息
     */
    //@PreAuthorize("@ss.hasPermi('ccapi:actionMapping:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取操作技能映射详细信息")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(ccapiActionMappingService.selectActionMappingById(id));
    }

    /**
     * 新增操作技能映射
     */
    //@PreAuthorize("@ss.hasPermi('ccapi:actionMapping:add')")
    @Log(title = "操作技能映射", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("新增操作技能映射")
    public AjaxResult add(@RequestBody ActionMappingDO ccapiActionMapping) {
        return toAjax(ccapiActionMappingService.insertActionMapping(ccapiActionMapping));
    }

    /**
     * 修改操作技能映射
     */
    //@PreAuthorize("@ss.hasPermi('ccapi:actionMapping:edit')")
    @Log(title = "操作技能映射", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("修改操作技能映射")
    public AjaxResult edit(@RequestBody ActionMappingDO ccapiActionMapping) {
        return toAjax(ccapiActionMappingService.updateActionMapping(ccapiActionMapping));
    }

    /**
     * 删除操作技能映射
     */
    //@PreAuthorize("@ss.hasPermi('ccapi:actionMapping:remove')")
    @Log(title = "操作技能映射", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    @ApiOperation("删除操作技能映射")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(ccapiActionMappingService.deleteActionMappingByIds(ids));
    }
}
